## initialization
import numpy
from PIL import Image
from inc_funs import *
import Image
import ImageDraw
import ImageFont
def imggen(novel):
    w,h=1024,768 ## this is the size image we want to create
    img = numpy.empty((w,h),numpy.uint32)
    img.shape=h,w ## set the array shape to our image shape; yes i know it seems backwards, but it's not!
    ## rajzolas
    for x in range(5000):
        c=0xFFFF0000+(((-1)^dice(1,2))*dice(1,5000))
        t1=dice(1,1000)
        t2=dice(1,1000)*2
        t3=dice(1,1000)
        t4=dice(1,1000)*2
        img[t1:t2,t3:t4]=c
    ## elmentes

    pilImage = Image.frombuffer('RGBA',(w,h),img,'raw','RGBA',0,1)
    pilImage.save('my.png')
    im = Image.open("my.png")
    draw = ImageDraw.Draw(im)
    novel=novel.split('\n')
    txd=40
    font = ImageFont.truetype("gur.ttf", txd)
    for x in range(len(novel)):
        draw.text((50, 50+(x*txd+5)), novel[x], font=font, fill=0)
    im.save('my.png')
    print "A kepet sikeresen elmentettem my.png neven"

